<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('VIP客户列表')"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li>
                            <label>用户类型：</label>
                            <select name="userType" th:with="type=${@dict.getType('sys_min_user_type')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label style="width: 95px;">是否超级VIP：</label>
                            <select name="isSuper" th:with="type=${@dict.getType('sys_member_is_super')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li>
                            <label>审批状态：</label>
                            <select name="auditStatus" th:with="type=${@dict.getType('sys_member_audit_status')}">
                                <option value="">所有</option>
                                <option th:each="dict : ${type}" th:text="${dict.dictLabel}"
                                        th:value="${dict.dictValue}"></option>
                            </select>
                        </li>
                        <li class="select-time">
                            <label>申请时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="startTime"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="endTime"/>
                        </li>
                        <li>
                            <label style="width: 105px;">关键字查询字段：</label>
                            <select name="fields">
                                <option value="devSn" selected>机柜SN</option>
                                <option value="appUserId">用户ID</option>
                                <option value="trueName">用户姓名</option>
                                <option value="phone">用户手机号</option>
                                <option value="partnerFullName">所属合作商</option>
                                <option value="merchantFullName">所属商户</option>
                                <option value="storeName">所属门店</option>
                            </select>
                            <input type="text" name="keywords"/>
                        </li>
                        <!--                        <li>-->
                        <!--                            <label>合作商ID：</label>-->
                        <!--                            <input type="text" name="partnerId"/>-->
                        <!--                        </li>-->
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>

        <div class="btn-group-sm" id="toolbar" role="group">
            <!--            <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="system:member:add">-->
            <!--                <i class="fa fa-plus"></i> 添加-->
            <!--            </a>-->
            <!--            <a class="btn btn-primary single disabled" onclick="$.operate.edit()"-->
            <!--               shiro:hasPermission="system:member:edit">-->
            <!--                <i class="fa fa-edit"></i> 修改-->
            <!--            </a>-->
            <!--            <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"-->
            <!--               shiro:hasPermission="system:member:remove">-->
            <!--                <i class="fa fa-remove"></i> 删除-->
            <!--            </a>-->
            <!--            <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:member:export">-->
            <!--                <i class="fa fa-download"></i> 导出-->
            <!--            </a>-->
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<script th:inline="javascript">
    var editFlag = [[${@permission.hasPermi('system:member:edit')}]];

    var promotionSuperVipFlag = [[${@permission.hasPermi('system:member:promotionSuperVip')}]];

    var removeFlag = [[${@permission.hasPermi('system:member:remove')}]];


    var relieveFlag = [[${@permission.hasPermi('system:member:relieve')}]];

    var userTypeDatas = [[${@dict.getType('sys_min_user_type')}]];
    var isSuperDatas = [[${@dict.getType('sys_member_is_super')}]];
    var auditStatusDatas = [[${@dict.getType('sys_member_audit_status')}]];
    var prefix = ctx + "system/member";

    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/remove",
            exportUrl: prefix + "/export",
            modalName: "VIP申请",
            columns: [{
                checkbox: true
            },
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'trueName',
                    title: '用户姓名(用户类型)',
                    formatter: function (value, row, index) {
                        return value + "(" + $.table.selectDictLabel(userTypeDatas, row.userType) + ")";
                    }
                },
                {
                    field: 'isSuper',
                    title: '是否超级VIP',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(isSuperDatas, value);
                    }
                },
                {
                    field: 'phone',
                    title: '用户手机号'
                },
                {
                    field: 'devSn',
                    title: '机柜SN'
                },
                {
                    field: 'partnerFullName',
                    title: '所属合作商'
                },
                {
                    field: 'merchantFullName',
                    title: '所属商户'
                },
                {
                    field: 'storeName',
                    title: '所属门店'
                },
                {
                    field: 'createTime',
                    title: '申请时间'
                },
                {
                    field: 'orderFreeMinute',
                    title: '每单前X分钟免费'
                },
                {
                    field: 'dailyOrderLimit',
                    title: '每天免费订单数'
                },
                {
                    field: 'auditStatus',
                    title: '审批状态',
                    formatter: function (value, row, index) {
                        return $.table.selectDictLabel(auditStatusDatas, value);
                    }
                },
                {
                    field: 'approvalTime',
                    title: '审批时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs ' + promotionSuperVipFlag + '" href="javascript:void(0)" onclick="promotionSuperVip(\'' + row.id + '\')"><i class="fa fa-edit"></i>升级为超级VIP</a> ');


                        actions.push('<a class="btn btn-danger btn-xs ' + relieveFlag + '" href="javascript:void(0)" onclick="relieve(\'' + row.id + '\')"><i class="fa fa-remove"></i>解除</a>');

                        return actions.join('');
                    }
                }]
        };
        $.table.init(options);
    });

    function promotionSuperVip(id) {
        var url = prefix + "/promotionSuperVip/" + id;
        $.modal.open("升级为超级VIP", url);
    }

    // 解除VIP
    function relieve(id) {
        var url = prefix + "/relieve";
        var data = {"id": id};
        $.modal.confirm("确定解除VIP吗？", function () {
            $.operate.submit(url, "post", "json", data);
        });
    }
</script>
</body>
</html>